<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/views/global/taglibs.jsp" %>
<base href="<%=basePath %>">
<%@include file="/views/global/include.jsp" %>

<link rel="stylesheet" href="static/javascript/global/ztree/css/zTreeStyle/zTreeStyle.css" />
<script type="text/javascript" src="static/javascript/global/ztree/js/jquery.ztree.core-3.5.js"></script>
<script type="text/javascript" src="static/javascript/global/ztree/js/jquery.ztree.excheck-3.5.js"></script>
<script type="text/javascript" src="static/javascript/global/ztree/js/jquery.ztree.exedit-3.5.js"></script>
<script type="text/javascript" src="static/bootstrap/js/jquery.bootstrap.min.js"></script>
<link rel="stylesheet" href="static/extjs/resources/css/ext-all.css" />
<style type="text/css">
        .ztree li span.button.add {margin-left:2px; margin-right: -1px; background-position:-144px 0; vertical-align:top; *vertical-align:middle}
</style>
<div class="col-xs-4">
	<ul id="treeBody" class="ztree"></ul>
	<script type="text/javascript">
	 	
	 	     var setting = {
	 	    		check: {
	 					enable: true,
	 					chkboxType: { "Y": "", "N": "" }
	 				},
 	    		async: {
 					enable: true,
 					url:"admin/mallCategory/getDirectChildsCheck",
 					autoParam:["id"],
 					otherParam:{"method":"get"},
 					dataFilter: filter
 				},	 
	 			
	 			view: {expandSpeed:""
	 			},
	 			data: {
	 				simpleData: {
						enable: true,
				        rootPId: -1
					
					}
	 			},
	 			callback: {
	 				onCheck: zTreeOnCheck
	 			}
	 		};
	 		
	 	     
	 	    function zTreeOnCheck(event, treeId, treeNode) {
	 	    	
	 	    	$.ajax({
					type: "POST",
					async: false,
					url: "admin/mallCategory/saveMallCatSearch",
					data:{cid: treeNode.id,itemId:art.dialog.data("itemId"),checked:treeNode.checked},
					dataType: "json",
					success: function(jsonData) {
						
					}
				});
	 	       
	 	   };
	 	   
	 		function filter(treeId, parentNode, childNodes) {
	 			if (!childNodes) return null;
	 			for (var i=0, l=childNodes.length; i<l; i++) {
	 				childNodes[i].name = childNodes[i].name.replace(/\.n/g, '.');
	 			}
	 			return childNodes;
	 		}
	 		
	 		function beforeRemove(treeId, treeNode) {
	 			var zTree = $.fn.zTree.getZTreeObj("treeBody");
	 			zTree.selectNode(treeNode);
	 			var confirmMsg =  "确认删除 节点 -- " + treeNode.name + " 吗？";
	 			var confirmRet=false;
	 			if(confirm(confirmMsg)){
	 				$.ajax({
						type: "POST",
						async: false,
						url: "admin/mallCategory/remove",
						data:{id: treeNode.id},
						dataType: "json",
						success: function(jsonData) {
							confirmRet=true;
						}
					});
	 			}
	 				
	 			return confirmRet;
	 		}
	 		
	 		function beforeRename(treeId, treeNode, newName) {
	 			$.ajax({
					type: "POST",
					url: "admin/mallCategory/rename",
					data:{id: treeNode.id,name:newName},
					dataType: "json",
					success: function(jsonData) {
						
					}
				});
	 			return true;
	 		}


	 		$(document).ready(function(){
	 	
	 			$.fn.zTree.init($("#treeBody"), setting);
	 		
	 		});

	</script>
	
</div>
<div class="col-xs-8">
	<div id="frameDiv"></div>
</div>
<%@include file="/views/global/AdminScripts.jsp" %>
